home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / System / Sample 2.4 Think C distribution / glob.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-25  |  10.1 KB  |  271 lines  |  [TEXT/KAHL]

  1. /*______________________________________________________________________
  2.  
  3.     glob.h - Global Declarations for Sample.
  4.     
  5.     Copyright © 1988, 1989, 1990, Northwestern University.
  6.  
  7.     This header file defines the constants, data types, and global
  8.     variables shared by the private modules in Sample.
  9.  
  10.     Note that the reusable modules are not permitted to include the
  11.     header file, but the virus detection and repair modules are permitted
  12.     to include it.    
  13. _____________________________________________________________________*/
  14.  
  15.  
  16. #ifndef __glob__
  17. #define __glob__
  18.  
  19. #ifndef __rpp__
  20. #include "rpp.h"
  21. #endif
  22.  
  23. #ifndef __rez__
  24. #include "rez.h"
  25. #endif
  26.  
  27.  
  28. /*______________________________________________________________________
  29.  
  30.     Constant Definitions. 
  31. _____________________________________________________________________*/
  32.  
  33.  
  34.  
  35. /* Other constants. */
  36.  
  37. #define  invertInterval       15            /* tick interval between inverts of
  38.                                                     small floppy icon during scan of
  39.                                                     floppy sequence */
  40. #define    zoomSlop                3            /* pixels to leave at top and bottom
  41.                                                     of zoomed windows */
  42. #define    staggerInitialOffset    3        /* pixel offset for first staggered window */
  43. #define    staggerOffset        20            /* pixel offset for subsequent staggered
  44.                                                     windows */
  45. #define    dragSlop                4            /* slop for DragWindow bounds rect */
  46. #define    minMainSize            295        /* min height of main window in pixels */
  47. #define    minHelpSize            100        /* min height of Help window in pixels */
  48. #define    beepDuration        10            /* sysbeep duration in ticks */
  49.  
  50. /* Tags for help system */
  51.  
  52. #define    tagFirstButton    300        /* first button - the other buttons
  53.                                                 are assigned tags 301 through 309 */
  54. #define    tagUpperRight    320        /* upper right corner of main window */
  55. #define    tagReport        321        /* report rectangle */
  56. #define    tagMainWind        500        /* main window */
  57. #define    tagHelpWind        501        /* help window */
  58. #define    tagHelpTcon        603        /* help window table of contents */
  59. #define    tagPrefBeep        330        /* prefs beep option */
  60. #define    tagPrefStation    331        /* prefs scanning station option */
  61. #define    tagPrefSave        332        /* prefs saved text file options */
  62. #define    tagPrefNotif    333        /* prefs notification options */
  63. #define    tagAbouWind        503        /* about window */
  64. #define    tagCmdBase        600        /* base for menu commands */
  65. #define    tagCmdMult        20            /* multiplier for menu commands */
  66.  
  67. /*______________________________________________________________________
  68.  
  69.     Type Declarations.
  70. _____________________________________________________________________*/
  71.  
  72.  
  73. /* Kinds of scans. */
  74.  
  75. typedef enum ScanKind {
  76.     allScan,                    /* all volumes */
  77.     volScan,                    /* selected volume */
  78.     foldScan,                /* folder */
  79.     fileScan,                /* file */
  80.     autoScan,                /* sequence of floppies */
  81.     fileFoldScan,            /* file or folder */
  82.     sysFileScan,            /* system file */
  83.     sysFoldScan,            /* system folder */
  84.     volSetScan,                /* set of volumes */
  85.     desktopScan                /* Finder desktop files */
  86. } ScanKind;
  87.  
  88. /* Scanning operations. */
  89.  
  90. typedef enum ScanOp {
  91.     checkOp                    /* scan */
  92. } ScanOp;
  93.  
  94. /* Notification options. */
  95.  
  96. typedef enum NotifOption {
  97.     notifDiamond,            /* only diamond in apple menu */
  98.     notifIcon,                /* also rotating icon in menu bar */
  99.     notifAlert                /* also alert */
  100. } NotifOption;
  101.  
  102. /* Window kinds. */
  103.  
  104. typedef enum WindKind {
  105.     mainWind,                /* main window */
  106.     helpWind,                /* help window */
  107.     prefWind,                /* prefs window */
  108.     abouWind,                /* about window */
  109.     daWind                    /* da window */
  110. } WindKind;
  111.  
  112. /* The standard Edit menu commands. */
  113. /* These are already defined in <DeskMgr.h>. */
  114. #if 0
  115. typedef enum EditCmd {
  116.     undoCmd,
  117.     editDummyCmd,    /* the separator line in the Edit menu */
  118.     cutCmd,
  119.     copyCmd,
  120.     pasteCmd,
  121.     clearCmd 
  122. } EditCmd;
  123. #else
  124. typedef short EditCmd;
  125. #endif
  126.  
  127. /* Window objects.  This struct records additional information about each
  128.     window, plus pointers to functions to handle the common window events
  129.     and commands.  The refCon field of each window record points to one
  130.     of these structs. */
  131.  
  132. typedef void (*FUpdate)(void);
  133. typedef void (*FActivate)(void);
  134. typedef void (*FDeactivate)(void);
  135. typedef void (*FResume)(void);
  136. typedef void (*FSuspend)(void);
  137. typedef void (*FClick)(Point where, short modifiers);
  138. typedef void (*FHelp)(Point where);
  139. typedef void (*FGrow)(short height, short width);
  140. typedef void (*FZoom)(void);
  141. typedef void (*FKey)(short key, short modifiers);
  142. typedef void (*FClose)(void);
  143. typedef void (*FDisk)(long message);
  144. typedef Boolean (*FSave)(void);
  145. typedef OSErr (*FPageSetup)(void);
  146. typedef OSErr (*FPrint)(Boolean printOne);
  147. typedef void (*FEdit)(EditCmd cmd);
  148. typedef void (*FAdjust)(void);
  149. typedef void (*FPeriodic)(void);
  150. typedef Boolean (*FDialogPre)(short key);
  151. typedef void (*FDialogPost)(short item);
  152.  
  153. typedef struct WindowObject {
  154.     WindKind                windKind;            /* which kind of window */
  155.     Boolean                moved;                /* true if moved or grown */
  156.     Rect                    sizeRect;            /* size rectangle */
  157.     FUpdate                update;                /* ptr to update function */
  158.     FActivate            activate;            /* ptr to activate function */
  159.     FDeactivate            deactivate;            /* ptr to deactivate function */
  160.     FResume                resume;                /* ptr to resume function */
  161.     FSuspend                suspend;                /* ptr to suspend function */
  162.     FClick                click;                /* ptr to click function */
  163.     FHelp                    help;                    /* ptr to help function */
  164.     FGrow                    grow;                    /* ptr to grow function */
  165.     FZoom                    zoom;                    /* ptr to zoom function */
  166.     FKey                    key;                    /* ptr to key function */
  167.     FClose                close;                /* ptr to close function */
  168.     FDisk                    disk;                    /* ptr to disk inserted function */
  169.     FSave                    save;                    /* ptr to save function */
  170.     FPageSetup            pageSetup;            /* ptr to page setup function */
  171.     FPrint                print;                /* ptr to print function */
  172.     FEdit                    edit;                    /* ptr to edit function */
  173.     FAdjust                adjust;                /* ptr to menu adjust function */
  174.     FPeriodic            periodic;            /* ptr to periodic function */
  175.     FDialogPre            dialogPre;            /* ptr to dialog event preprocessor */
  176.     FDialogPost            dialogPost;            /* ptr to dialog event postprocessor */
  177. } WindowObject;
  178.  
  179. /* Saved window state.  See HIN 6. */
  180.  
  181. typedef struct WindState {
  182.     Rect                    userState;                /* user state rectangle */
  183.     Boolean                zoomed;                    /* true if in zoomed (standard) state */
  184.     Boolean                moved;                    /* true if moved or grown */
  185. } WindState;
  186.  
  187. /* Preferences. */
  188.  
  189. typedef struct PrefsType {
  190.     char                    version[30];            /* version number */
  191.     WindState            mainState;                /* main window state */
  192.     WindState            helpState;                /* help window state */
  193.     WindState            prefState;                /* prefs window state */
  194.     WindState            abouState;                /* about window state */
  195.     rpp_PrtBlock        mainPrint;                /* main window print block */
  196.     rpp_PrtBlock        helpPrint;                /* help window print block */
  197.     TPrint                mainPrintRec;            /* main window print record */
  198.     TPrint                helpPrintRec;            /* help window print record */
  199.     short                    numOpenWind;            /* number of open windows */
  200.     WindKind                openWind[5];            /* list of open windows, in front to
  201.                                                             back order */
  202.     short                    helpScrollPos;            /* help window scroll position */
  203.     short                    beepCount;                /* beep count pref */
  204.     Boolean                scanningStation;        /* scanning station pref */
  205.     ScanOp                scanningStationOp;    /* scanning station op - 
  206.                                                             scan or disinfect */
  207.     OSType                repCreator;                /* report creator type pref */
  208.     OSType                docCreator;                /* document creator type pref */
  209.     OSType                repOtherCre;            /* report "other" creator type */
  210.     OSType                docOtherCre;            /* doc "other" creator type */
  211.     NotifOption            notifOption;            /* notification option pref */
  212. } PrefsType;
  213.  
  214. /*______________________________________________________________________
  215.  
  216.     Global Variables.
  217. _____________________________________________________________________*/
  218.  
  219.  
  220. /* The following variables are set during initialization, and never
  221.     changed thereafter. */
  222.     
  223. extern ControlHandle    Controls[numControls];    /* main window control handles */
  224. extern Handle            Report;                    /* handle to main window report record */
  225. extern Rect                DragRect;                /* drag rectangle */
  226. extern Boolean            SysHasShutDown;        /* true if shutdown trap exists */
  227. extern long                LongSleep;                /* long sleep time */
  228. extern Rect                RectList[numRects];    /* rectangle list */
  229. extern CursHandle        Watch;                    /* handle to watch cursor */
  230. extern CursHandle        HelpCurs;                /* handle to help cursor */
  231. extern CursHandle        IBeamCurs;                /* handle to ibeam cursor */
  232. extern short            SysRefNum;                /* system file ref num */
  233. extern short            SysVol;                    /* system vol ref num */
  234. extern long                SysDirID;                /* blessed folder dir id */
  235. extern short            DfectRefNum;            /* Sample's file ref num */
  236. extern short            DfectVol;                /* Sample's vol ref num */
  237. extern Boolean            OldRom;                    /* true if 64K rom */
  238. extern Boolean            Initialized;            /* true when initialization complete */
  239.  
  240. /*    The following variables are changed after intialization. */
  241.                                                     
  242. extern PrefsType        Prefs;                    /* preferences */
  243. extern Boolean            Done;                        /* true when time to quit */
  244. extern Boolean            MenuPick;                /* true if command was via menu pick */
  245. extern Boolean            Scanning;                /* true while scan in progress */
  246. extern Boolean            FloppyWait;                /* true while waiting for floppy insert */
  247. extern Boolean            Canceled;                /* true if scan canceled */
  248. extern Boolean            HelpMode;                /* true if help mode */
  249. extern Boolean            InForeground;            /* true if running in foreground */                                                                
  250. extern Boolean            NoMemFullAlert;        /* true to tell grow zone proc to 
  251.                                                             return 0 on mem full instead of 
  252.                                                             posting mem full alert */
  253. extern ScanKind        CurScanKind;            /* kind of scan */
  254. extern long                NumScanned;                /* number of files scanned counter */
  255. extern long                NumInfected;            /* number of files infected counter */
  256. extern long                NumErrors;                /* number of errors counter */
  257. extern Boolean            Notified;                /* true if notification posted */
  258. extern NMRec            NotifRec;                /* Notification Manager record */
  259. extern Str255            NotifString;            /* notification string */
  260. extern Boolean            VolIsLocal;                /* true if vol being scanned is
  261.                                                             local vol (for Zig) */
  262.  
  263. extern long                TotFiles;            /* total number of files scanned */
  264. extern long                TotErrors;            /* total number of errors */
  265. extern long                TotInfected;        /* total number of infected files */
  266. extern long                TotStillInf;        /* total number of infected files
  267.                                                         not repaired */
  268. extern long                TotNoAccess;        /* total number of folders with 
  269.                                                         insufficient access rights */                                            
  270.  
  271. #endif